package com.example.portlocalforward.sshmanage;

import com.example.portlocalforward.controller.model.PortLocalForwardResponse;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Data
@EqualsAndHashCode(of = { "host", "port", "username" })
@AllArgsConstructor
@NoArgsConstructor
public class SessionKey {
    private String host; // 隧道地址
    private int port; // 端口
    private String username; // 用户名
    private String password; // 密码

    public SessionKey(String host, int port, String username) {
        this.host = host;
        this.port = port;
        this.username = username;
    }

    public static SessionKey of(PortLocalForwardResponse response) {
        return new SessionKey(response.getSshTunnelIp(), response.getSshTunnelPort(),
                response.getSshTunnelUsername(), response.getSshTunnelPassword());
    }
}
